﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics.Contracts;
using System.Linq;

namespace $safeprojectname$.Settings
{
    public class BaseSettings : IBaseSettings
    {
        #region members
        ConfigurationFilePath _configurationFilePath = new ConfigurationFilePath();
        string _connectionStringNameAdoNet = "ProjectAdoNet";
        string _connectionStringNameNHibernate = "ProjectNHibernate";
        string _defaultConnectionStringAdoNet;
        ConnectionStringSettings _defaultConnectionStringSettingsAdoNet;

        short _defaultListRowCount = 25;
        bool _enableDbDao = true;
        bool _enableNHDao = true;
        bool _enableSessionKeeper = true;
        bool _enableXmlDao = true;

        string _fileCacheDbPath = "DbCache.xml";
        string _fileCacheStaticPath = "StaticCache.xml";
        string _prefixForNotFoundTranslation = "$";
        string _daoDefaultLikeCollation = "Latin1_General_CI_AS";

        #endregion members

        #region Project settings
        public virtual string PrefixForNotFoundTranslation
        {
            get { return _prefixForNotFoundTranslation; }
            set { _prefixForNotFoundTranslation = value; }
        }

        public virtual short DefaultListRowCount
        {
            get { return _defaultListRowCount; }
            set { _defaultListRowCount = value; }
        }

        public virtual bool EnableSessionKeeper
        {
            get { return _enableSessionKeeper; }
            set { _enableSessionKeeper = value; }
        }

        public virtual bool ValidateRequestOnController { get; set; }

        public virtual string ConnectionStringNameNHibernate
        {
            get { return _connectionStringNameNHibernate; }
            set { _connectionStringNameNHibernate = value; }
        }

        public virtual string ConnectionStringNameAdoNet
        {
            get { return _connectionStringNameAdoNet; }
            set { _connectionStringNameAdoNet = value; }
        }

        public virtual string DefaultConnectionStringAdoNet
        {
            get
            {
                return _defaultConnectionStringAdoNet
                    ?? (_defaultConnectionStringAdoNet = DefaultConnectionStringSettingsAdoNet.ConnectionString);
            }
        }

        public virtual ConnectionStringSettings DefaultConnectionStringSettingsAdoNet
        {
            get
            {
                return _defaultConnectionStringSettingsAdoNet
                    ?? (_defaultConnectionStringSettingsAdoNet = ConfigurationManager.ConnectionStrings[ConnectionStringNameAdoNet]);
            }
        }

        public virtual bool UseCurrentRole { get; set; }
        public virtual IDictionary<string, string> RolesConvertor { get; set; }
        public virtual IEnumerable<WriteAction> WriteActions { get; set; }
        public virtual Type FactoryProviderType { get; set; }

        /// <summary>
        ///     Contains the relative path to the configuration files
        /// </summary>
        public virtual ConfigurationFilePath ConfigurationFilePath
        {
            get { return _configurationFilePath; }
            set
            {
                Contract.Requires(value.Is(), " ConfigurationFilePath cannot be set to null");
                _configurationFilePath = value;
            }
        }

        public virtual bool EnableNHDao
        {
            get { return _enableNHDao; }
            set { _enableNHDao = value; }
        }

        public virtual bool EnableDbDao
        {
            get { return _enableDbDao; }
            set { _enableDbDao = value; }
        }

        public virtual bool EnableXmlDao
        {
            get { return _enableXmlDao; }
            set { _enableXmlDao = value; }
        }

        /// <summary>
        ///     The path to the file, which serves as a mark for Caches to be cleared.
        ///     On web farm could be set to external file (e.g. "c:\DbCache.xml")
        ///     Default value: "DbCache.xml"
        /// </summary>
        public virtual string FileCacheDbPath
        {
            get { return _fileCacheDbPath; }
            set { _fileCacheDbPath = value; }
        }

        /// <summary>
        ///     The path to the file, which serves as a mark for Caches to be cleared.
        ///     On web farm could be set to external file (e.g. "c:\StaticCache.xml")
        ///     Default value: "StaticCache.xml"
        /// </summary>
        public virtual string FileCacheStaticPath
        {
            get { return _fileCacheStaticPath; }
            set { _fileCacheStaticPath = value; }
        }

        /// <summary>
        ///     In a web farm, should be set to true. All Facades static fields will be reloaded
        ///     when the file in the FileCacheStaticPath is changed (LastAccess date is changed).
        ///     Default value is "false" (only needed on a web farm).
        ///     NOTE on a single worker process, Facade static members should be cleaned using the Change event
        /// </summary>
        public virtual bool AllowFileCacheDependencyForStatic { get; set; }

        /// <summary>
        /// Data layer. When LIKE expresion is created, this Collation will be used. (default is Latin1_General_CI_AS)
        /// </summary>
        public virtual string DaoDefaultLikeCollation
        {
            get { return _daoDefaultLikeCollation; }
            set { _daoDefaultLikeCollation = value; }
        }

        #endregion Project settings
    }
}